<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use App\CustHub\Constants\RoomInviteLogTypeConstants;
use Mine\MineModel;

/**
 * @property int $id 
 * @property int $uid 
 * @property int $main_uid 
 * @property string $name 方案名称
 * @property int $target_room_type 目标群类型：0=按机器人选群 1=按群选择机器人 2=按条件筛选群
 * @property array $target_room_config 目标群配置
 * @property int $room_member_limit 群成员上限
 * @property int $invite_rule 拉群规则
 * @property int $invite_interval 拉取间隔
 * @property int $full_room_replacement 已满群替补方式:0=不替补 1=循环替补
 * @property int $priority_use_backup_room 是否优先使用替补群：0=否 1=是
 * @property int $auto_create_room_switch 自动新建客户群:0=关闭 1=开启
 * @property array $auto_create_room_config 自动新建客户群配置
 * @property int $resend_unjoined_switch 未进群再次邀请:0=关闭 1=开启
 * @property array $resend_unjoined_config 未进群再次邀请:配置
 * @property int $resend_joined_switch 已进群再次营销:0=关闭 1=开启
 * @property array $resend_joined_config 已进群再次营销配置
 * @property int $exclude_existing_switch 已在群聊不触发：0=关闭 1=开启
 * @property int $exclude_historical_switch 曾在群聊不触发：0=关闭 1=开启
 * @property int $status 状态：0=禁用 1=启用
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property-read null|\Hyperf\Database\Model\Collection|ChRoomInviteActiveRoom[] $activeRoomList 
 */
class ChRoomInviteScheme extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_room_invite_scheme';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'uid', 'main_uid', 'name', 'target_room_type', 'target_room_config', 'room_member_limit', 'invite_rule', 'invite_interval', 'full_room_replacement', 'priority_use_backup_room', 'auto_create_room_switch', 'auto_create_room_config', 'resend_unjoined_switch', 'resend_unjoined_config', 'resend_joined_switch', 'resend_joined_config', 'exclude_existing_switch', 'exclude_historical_switch', 'status', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'uid' => 'integer', 'main_uid' => 'integer', 'target_room_type' => 'integer', 'target_room_config' => 'array', 'room_member_limit' => 'integer', 'invite_rule' => 'integer', 'invite_interval' => 'integer', 'full_room_replacement' => 'integer', 'priority_use_backup_room' => 'integer', 'auto_create_room_switch' => 'integer', 'auto_create_room_config' => 'array', 'resend_unjoined_switch' => 'integer', 'resend_unjoined_config' => 'array', 'resend_joined_switch' => 'integer', 'resend_joined_config' => 'array', 'exclude_existing_switch' => 'integer', 'exclude_historical_switch' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function activeRoomList()
    {
        return $this->hasMany(ChRoomInviteActiveRoom::class, 'scheme_id', 'id')->where('scheme_type', RoomInviteLogTypeConstants::ROOM_INVITE_SCHEME);
    }
}
